<?php
/**
 * Created by PhpStorm.
 * User: yellow
 * Date: 2019/5/25
 * Time: 17:29
 */

namespace app\admin\validate;

use think\Validate;

class BusBusiness extends Validate
{

    /**
     * 定义验证规则
     * 格式：'字段名'	=>	['规则1','规则2'...]
     *
     * @var array
     */
    protected $rule = [
        '__token__' => 'token',

    ];

    /**
     * 定义错误信息
     * 格式：'字段名.规则名'	=>	'错误信息'
     *
     * @var array
     */
    protected $message = [
        'password.min' => '密码不能少于6位!'
    ];

    /**
     * 核对密码
     */
    protected function checkPassword($value, $rule, $data){
        if (!$value){
            return true;
        }
        if (strlen($value) < 6){
            return "密码不能少于6位!";
        }
        if ($value != $data['r_password']){
            return "两次输入的密码不一致";
        }
        return true;
    }
}